package demo2;

public class LeetCode11 {
    public int maxArea(int[] arr) {
        int n = arr.length;
        int sum = 0;
        int left = 0, right = n - 1;
        while(left < right) {
            int len = right - left;
            int high = Math.min(arr[left], arr[right]);
            sum = Math.max(sum, high * len);
            if(arr[left] < arr[right]) left++;
            else right--;
        }
        return sum;
    }
}
